
<?php
		
	$var = @$_GET['id'] ;
	
	//connect to your database ** EDIT REQUIRED HERE **
	include('config.php');
	
	// Build SQL Query  
	//$query = "SELECT * FROM tbartifacts WHERE Title LIKE \"%$trimmed%\" OR Text LIKE \"%$trimmed%\" " ; 
	
	$query = "SELECT tbartifacts.Id AS ArtifactsId, tbartifacts.Title, tbartifacts.Text, tbartifacts_type.Name, 
	          tbartifacts_type.Id As TypeId, tbusers.Id AS AuthorId, tbusers.Name AS Author
			  FROM tbartifacts, tbartifacts_type, tbusers 
			  WHERE tbartifacts.Id = \"$var\"  
			  AND tbartifacts.Type = tbartifacts_type.Id AND tbartifacts.Author = tbusers.Id";
	
	
	
	 	
	mysql_query("set names utf8");
	 
	$numresults = mysql_query($query);
	 
	if (!$numresults) 
	{
		die('Invalid query: ' . mysql_error());
	}
					
		 
	$row = mysql_fetch_assoc($numresults);
	
	// If the Author is diferent than session user Id 
	if($row["AuthorId"] != $_SESSION['userid'])
	{
		redirect('index.php');
	}	
		
	echo (" <form enctype='multipart/form-data' name='uploadForm' action='lib/edit_uploader.php' method='post'> ");
	
        echo (" <input type='hidden' name='artifactsId' id='artifactsId' value='".$row["ArtifactsId"]."'  /> ");
		
		echo (" Title: ");
		echo (" <input type='text' name='titulo' id='titulo' class='' value='".$row["Title"]."'  /> ");
		echo (" <br/><br/><br/> ");
		
		echo (" Type: ");		
		include("lib/getTypes_editarmodelo.php");			
		echo (" <br/><br/><br/> ");
		
		echo (" Author: ");
		echo ("<input type='text' name='autor' id='autor' value='".$row["Author"]."' />");
		echo (" <br/><br/><br/> ");
				
		echo (" Description: ");
		echo (" <textarea name='texto'  id='texto' rows='6' cols='80' >".$row["Text"]."</textarea> ");
		echo (" <br/><br/><br/> ");
		
	 
		echo ("Image:");	   
		echo ("<input type='file' name='uploadimage' id='uploadimage' accept='image/jpeg' />");
	 	echo (" <br/><br/> ");
				
		echo ("File: ");
		echo ("<input type='file' name='uploadfile' id='uploadfile' />");
		                   
		echo (" <br/><br/><br/> ");
		echo ("Send: ");
		echo (" <input  type='submit' name='submit' value='submit' onclick='checkForm();' />");
		echo (" <br/><br/><br/> ");
		
		echo(" </form> ");
	
	  
?>